<template>
    <div class="newsinfo-container">
        <h1 class="title">{{newsinfo.title}}</h1>
        <p class="subtitle">
            <span>发表时间：{{newsinfo.time}}</span>
            <span>点击：{{newsinfo.click}}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsinfo.content"></div>
        <!--评论组件-->
        <comment-box></comment-box>
    </div>
</template>

<script>
    // 1.引入评论组件
    import comment from '../subcomponents/comment.vue'

    export default {
        data(){
            return{
                //获取router中传的id值保存在data中
                id:this.$route.params.id,
                newsinfo:[]
            }
        },
        created(){
            this.getNewsinfo()
        },
        methods:{
            getNewsinfo(){
                this.$http.get('/api/getnew').then(res=>{
                    this.newsinfo=res.body.data[0];
                    console.log(this.newsinfo)
                })
            }
        },
        components:{
             'comment-box':comment
        }
    }
</script>

<style lang="scss" scoped>
    .newsinfo-container{
        padding:0 4px;
    .title{
        font-size: 16px;
        text-align: center;
        margin: 15px 0;
        color: red;
    }
    .subtitle{
        font-size: 13px;
        color: #226aff;
        display: flex;
        justify-content:space-between;
    }
        .content{
            color:grey;
            font-size: 14px;
        }
    }

</style>